package com.mashibing.singleton;

/**
 * 单例模式-饿汉式的第二种写法
 */
public class Mgr02 {
    private static Mgr02 INSTANCE;
    static {
        INSTANCE = new Mgr02();
    }
    private Mgr02(){}

    public static Mgr02 getInstance(){
        return INSTANCE;
    }

    public static void main(String[] args) {
        Mgr02 instance = Mgr02.getInstance();
        Mgr02 instance1 = Mgr02.getInstance();
        System.out.println(instance == instance1);
        System.out.println(instance.hashCode());
        System.out.println(instance1.hashCode());
    }
}
